<?php
declare (strict_types = 1);

namespace app\api\controller\v1;


use think\facade\Request;
use app\api\service\StatusCode;
use app\api\service\UserToken;
use app\api\model\StuCourse as ModelStuCourse;
use app\api\validate\ParamMustBePostiveInt;
/**
 * 学生端课程管理类
 */
class StuCourse extends Api
{
    /**
     * 获取课程
     */
    public function index()
    {
        $uid =  UserToken::getCurrentUid();
        $data = ModelStuCourse::getStuCourse($uid);
        exit(json_encode($data));
    }

    /**
     * 
     * 获取课程所有阶段
     */

    public function read()
    {
        
        $course_id = (new ParamMustBePostiveInt('course_id'))->paramCheck();
        $stage = (new ParamMustBePostiveInt('stage'))->paramCheck();
        $data = ModelStuCourse::getStuCourseAllInfo($course_id,$stage);
        exit(json_encode($data));
    }

    /**
     * 
     * 获取单独阶段下内容
     * 
     */

    public function get()
    {
        $stage_id = (new ParamMustBePostiveInt('stage_id'))->paramCheck();
        $data = ModelStuCourse::getStudentWeekCourse($stage_id);
        exit(json_encode($data));
    }
}